package com.za.wbw.dao.shop.impl;

import java.util.List;
import java.util.Map;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import com.za.wbw.dao.shop.ProductDao;
import com.za.wbw.model.shop.ProductInfo;

@SuppressWarnings("unchecked")
public class ProductDaoImpl extends SqlMapClientDaoSupport implements ProductDao {
	// 查询产品列表
	public List<ProductInfo> queryProductPage(Map<String, Object> pars) throws Exception{
		return (List<ProductInfo>)getSqlMapClientTemplate().queryForList("shop.queryProductPage", pars);
	}
	// 查询产品总数
	public int queryProductCount(Map<String, Object> pars) throws Exception{
		return (Integer)getSqlMapClientTemplate().queryForObject("shop.queryProductCount", pars);
	}
	// 查询产品信息
	public ProductInfo queryProductInfo(int productId) throws Exception{
		return (ProductInfo)getSqlMapClientTemplate().queryForObject("shop.queryProductInfo", productId);
	}
	// 保存产品信息
	public ProductInfo saveProductInfo(ProductInfo info) throws Exception{
		getSqlMapClientTemplate().insert("shop.saveProductInfo", info);
		return info;
	}
	// 编辑产品信息
	public void updateProductInfo(ProductInfo info) throws Exception{
		getSqlMapClientTemplate().update("shop.updateProductInfo", info);
	}
	// 更新下架
	public void updateProductStatus(Map<String, Object> pars) throws Exception{
		getSqlMapClientTemplate().update("shop.updateProductStatus", pars);
	}
}
